package cc.spider.demo;

import cc.spider.core.SpiderCore;
import cc.spider.datapipe.SimpleDataPipe;
import cc.spider.fetcher.SimpleFetcher;
import cc.spider.model.SpiderConfig;
import cc.spider.model.TaskInfo;
import cc.spider.processor.SimpleDataProcessor;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        SpiderConfig spiderConfig = new SpiderConfig();
        spiderConfig.setFetcher(new SimpleFetcher());
        spiderConfig.setDataProcess(new SimpleDataProcessor());
        spiderConfig.addDataPipe(new SimpleDataPipe());
        SpiderCore spiderCore = new SpiderCore(spiderConfig);
        List<TaskInfo> taskInfos = new ArrayList<>();
        TaskInfo taskInfo = new TaskInfo();
        taskInfos.add(taskInfo);
        spiderCore.addTasks(taskInfos);
        spiderCore.start();
        /*new Thread(() -> {
            int i = 1;
            while (i-- > 0) {
                System.out.println("start：" + spiderCore.start());
                System.out.println("exit：" + spiderCore.exit());
                *//*System.out.println("stop：" + spiderCore.stop());
                try {
                    Thread.sleep(6000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("resume：" + spiderCore.resume());
                System.out.println("exit：" + spiderCore.exit());*//*
                System.out.println("--------");
            }
        }).start();*/

       /* new Thread(() -> {
            int i = 1;
            while (i-- > 0) {
                System.out.println("start：" + spiderCore.start());
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("stop：" + spiderCore.stop(1));
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("stop：" + spiderCore.stop());
            }
        }).start();*/
    }
}
